home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: REQUEST: Recursive functions
- Date: Sun, 24 Mar 96 01:24:55 GMT
- Organization: none
- Message-ID: <827630695snz@genesis.demon.co.uk>
- References: <4h7lft$8ql@cis.clark.edu> <3150334B.1802@willows.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <3150334B.1802@willows.com>
- tarang@willows.com "Tarang Deshpande" writes:
-
- >Michael Talmage wrote:
- >>
- >> I need some help to write a recursive function that will move a mouse through
- >> a maze to find some cheese at the end. My instructor did not really teach us
- >> how to write recursive functions in class. Any help will be appreciated.
- >>
- >
- >I'm not going to tell you the answer but here is a quick leson in
- >recursion. First of all anything you do recursively can be done
- >using loops. But using loops is more complicated and cumbersome whereas
- >recursion is more elegant and simple.
-
- In the relatively few cases that model well recursively that is true,
- otherwise it is not. This is somewhat language dependent but you are
- posting to comp.lang.c.
-
- > However this does not mean that
- >you should always use recusion because recursion make heavy use of the
- >stack and this can cause you to run out of memory.
-
- Even if the C language guaranteed tail-end recursion elimination you
- would still write iterative loops as loops.
-
- >What recusion does is to divide the problem into two or more parts.
-
- It defines the problem in terms of a simpler form of itself. It must
- eventually reach a point where the solution can be determined directly or
- some other termination condition for it to be valid (i.e. not continue
- on indefinitely).
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-